package com.view;

import java.awt.ComponentOrientation;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;

import javax.swing.ImageIcon;
import javax.swing.JPanel;

public class ImagePanel extends JPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = -277526402275677369L;
	public static final int TAXI_LANE_BACKGROUND = 0;
	public static final int SKY_BACKGROUND = 1;
	public static final int HANGAR = 2;
	public static final int RUNWAY = 3;
	public static final int STACKLANE = 4;
	public static final int PLATAFORMA = 5;
	public static final int ATERRIZAJE = 6;

	
	private Image image;
	private Dimension panelSize;

	public ImagePanel(int backGround) {
		try {
			
			switch (backGround) {
			case TAXI_LANE_BACKGROUND:
				image =  new ImageIcon(getClass().getResource("/images/background/TaxiLane.png")).getImage();
				break;
			case SKY_BACKGROUND:
				image =  new ImageIcon(getClass().getResource("/images/background/sky_loop.gif")).getImage();
				break;
			case HANGAR:
				image =  new ImageIcon(getClass().getResource("/images/background/Hangar.png")).getImage();
				break;
			case RUNWAY:
				image =  new ImageIcon(getClass().getResource("/images/background/Runway.png")).getImage();
				break;
			case STACKLANE:
				image =  new ImageIcon(getClass().getResource("/images/background/stackLane.png")).getImage();
				break;
			case PLATAFORMA:
				image =  new ImageIcon(getClass().getResource("/images/background/plafaforma.png")).getImage();
				break;
			case ATERRIZAJE:
				image =  new ImageIcon(getClass().getResource("/images/background/landing.png")).getImage();
				break;
			default:
				break;
			}
			
			panelSize = new Dimension(image.getWidth(null), image.getHeight(null));
            setPreferredSize(panelSize);
            setMinimumSize(panelSize);
            setMaximumSize(panelSize);
            setSize(panelSize);
            
		} catch (Exception e) {
			System.out.println(e.getMessage());
		}
		applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
	}

	public void paintComponent(Graphics g) {
		g.drawImage(image, 0, 0, null);
	}
	
	public Image getImage() {
		return image;
	}
	
	@Override
	public Dimension getSize() {
		// TODO Auto-generated method stub
		return panelSize;
	}
	
	public static ImageIcon createSky(){
		return new ImageIcon(ImagePanel.class.getResource("/images/background/sky_loop.gif"));
	}
	
}
